package com.zz.schoolwall.controller;

import com.zz.common.utils.PageUtils;
import com.zz.common.utils.Query;
import com.zz.schoolwall.domain.SchoolWallLikeDO;
import com.zz.schoolwall.service.SchoolWallLikeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@RequestMapping("/schoolwall/like")
@Controller
public class SchoolWallLikeController {
	@Autowired
	SchoolWallLikeService schoolWallLikeService;


	@GetMapping("/edit/{type}/{id}")
	String editComment(@PathVariable("id") Long id,@PathVariable("type") String type, Model model) {
		model.addAttribute("id", id);
		model.addAttribute("type", type);
		return "schoolwall/info/edit_like";
	}


	@ResponseBody
	@GetMapping("/list/{type}/{id}")
	public PageUtils list(@PathVariable("id") Long id,@PathVariable("type") String type,@RequestParam Map<String, Object> params) {
		params.put("likeType",type);
		params.put("likeTypeId",id);
		Query query = new Query(params);
		List<SchoolWallLikeDO> reList = schoolWallLikeService.list(query);
		int total = schoolWallLikeService.count(query);
		PageUtils pageUtils = new PageUtils(reList, total);
		return pageUtils;
	}
}
